package ice.dao.util;

/**
 * SqlObject
 * 
 * @author abiao
 */
public class SqlObject {

    /**
     * SQL语句
     */
    private String sql;

    /**
     * SQL参数
     */
    private Object[] params;

    public SqlObject() {
    }

    public SqlObject(String sql) {
        this.sql = sql;
    }

    public SqlObject(String sql, Object[] params) {
        this.sql = sql;
        this.params = params;
    }

    /**
     * @return the sql
     */
    public String getSql() {
        return sql;
    }

    /**
     * @param sql the sql to set
     */
    public void setSql(String sql) {
        this.sql = sql;
    }

    /**
     * @return the params
     */
    public Object[] getParams() {
        return params;
    }

    /**
     * @param params the params to set
     */
    public void setParams(Object[] params) {
        this.params = params;
    }

    @Override
    public String toString() {
        StringBuffer sb = new StringBuffer();
        sb.append(sql);
        if (params != null) {
            for (int i = 0; i < params.length; i++) {
                sb.append("\n" + (i + 1) + ": " + params[i]);
            }
        }
        return sb.toString();
    }
}
